<html xmlns="http://www.w3.org/1999/xhtml">
  <head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
    <meta name="layout" content="bolao" />
  <g:set var="entityName" value="${message(code: 'group.label', default: 'Group')}" />
  <title><g:message code="default.edit.label" args="[entityName]" /></title>
  </head>
  <body>
    <div class="body">
      <g:if test="${flash.message}">
        <div class="message">${flash.message}</div>
      </g:if>
      <g:hasErrors bean="${group}">
        <div class="errors">
          <g:renderErrors bean="${group}" as="list" />
        </div>
      </g:hasErrors>
      <g:form method="post" >
        <g:hiddenField name="id" value="${group?.id}" />
        <g:hiddenField name="version" value="${group?.version}" />
        <div class="dialog">
        <fieldset>
          <legend><g:message code="default.edit.label" args="[entityName]" /></legend>
          <table>
            <tbody>
              <tr class="prop">
                <td valign="top" class="name">
                  <label for="name"><g:message code="group.name.label" default="Name" />:</label>
                </td>
                <td valign="top" class="value ${hasErrors(bean: group, field: 'name', 'errors')}">
                  <g:textField size="1" name="name" maxlength="1" value="${group?.name}" />
                </td>
              </tr>

            <tr class="prop">
              <td valign="top" class="name">
                <label for="cup"><g:message code="group.cup.label" default="Cup" />:</label>
              </td>
              <td valign="top" class="value ${hasErrors(bean: group, field: 'cup', 'errors')}">
               <g:select name="cup.id" from="${mz.matafe.bolao.Cup.list()}" optionKey="id"  optionValue="year" value="${group?.cup?.id}" noSelection="['null': '']" />
            </td>
            </tr>
            <tr class="prop">
              <td valign="top" class="name">
                <label for="active"><g:message code="group.active.label" default="Active" />:</label>
              </td>
              <td valign="top" class="value ${hasErrors(bean: group, field: 'active', 'errors')}">
                <g:checkBox name="active" value="${group?.active}" />
              </td>
            </tr>
            <tr class="prop">
              <td valign="top" class="name">
                <label for="teams"><g:message code="group.teams.label" default="Teams" />:</label>
              </td>
              <td valign="top" class="value ${hasErrors(bean: group, field: 'teams', 'errors')}">
                <ul>
                  <g:each in="${group?.teams?}" var="t">
                    <li><g:link controller="team" action="show" id="${t.id}">${t?.name?.encodeAsHTML()}</g:link></li>
                  </g:each>
                </ul>
                <g:link controller="team" action="create" params="['group.id': group?.id]">${message(code: 'default.add.label', args: [message(code: 'team.label', default: 'Team')])}</g:link>
            </td>
            </tr>
            </tbody>
          </table>
        </fieldset>
        </div>
        <div class="buttons">
          <span class="button"><g:actionSubmit class="save" action="update" value="${message(code: 'default.button.update.label', default: 'Update')}" /></span>
          <span class="button"><g:actionSubmit class="delete" action="delete" value="${message(code: 'default.button.delete.label', default: 'Delete')}" onclick="return confirm('${message(code: 'default.button.delete.confirm.message', default: 'Are you sure?')}');" /></span>
        </div>
      </g:form>
    </div>
  </body>
</html>
